package cn.itcast.jk.service.impl;

import java.io.Serializable;
import java.util.List;
import java.util.Map;
import java.util.UUID;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.itcast.jk.dao.ContractProductDao;
import cn.itcast.jk.domain.ContractProduct;
import cn.itcast.jk.pagination.Page;
import cn.itcast.jk.service.ContractProductService;

@Service
public class ContractProductServiceImpl implements ContractProductService{
	@Autowired
	ContractProductDao contractProductDao;
	
	@Override
	public List<ContractProduct> findPage(Page page) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<ContractProduct> find(Map paraMap) {
		// TODO Auto-generated method stub
		return contractProductDao.find(paraMap);
	}

	@Override
	public ContractProduct get(Serializable id) {
		// TODO Auto-generated method stub
		return contractProductDao.get(id);
	}

	@Override
	public void insert(ContractProduct contractProduct) {
		// TODO Auto-generated method stub
		//设置id
		contractProduct.setId(UUID.randomUUID().toString());
		//计算总金额
		contractProduct.setAmount(contractProduct.getPrice()*contractProduct.getCnumber());
		contractProductDao.insert(contractProduct);
	}

	@Override
	public void update(ContractProduct contractProduct) {
		// TODO Auto-generated method stub
		//计算总金额
		contractProduct.setAmount(contractProduct.getPrice()*contractProduct.getCnumber());
		contractProductDao.update(contractProduct);
	}

	@Override
	public void deleteById(Serializable id) {
		// TODO Auto-generated method stub
		contractProductDao.deleteById(id);
	}

	@Override
	public void delete(Serializable[] ids) {
		// TODO Auto-generated method stub
		contractProductDao.delete(ids);
	}

	@Override
	public List<ContractProduct> findByControctId(Map map) {
		return contractProductDao.find(map);
	}

}
